import Vue from 'vue';
import VueRouter from 'vue-router';
import Routers from './router';
import Vuex from 'vuex';
import Util from './libs/util';
import App from './app.vue';

/*******************************************/
// 全局注册所有vux组件
import {
    Group, Cell, Panel, Divider, Swiper, SwiperItem, Card, XImg
} from 'vux';
import 'vux/src/styles/reset.less';

Vue.component('group', Group);
Vue.component('cell', Cell);
Vue.component('panel', Panel);
Vue.component('divider', Divider);
Vue.component('swiper', Swiper);
Vue.component('swiper-item', SwiperItem);
Vue.component('card', Card);
Vue.component('x-img', XImg)


/*******************************************/

Vue.use(VueRouter);
Vue.use(Vuex);


// 路由配置
const RouterConfig = {
    mode: 'hash',
    routes: Routers
};
const router = new VueRouter(RouterConfig);

// router.beforeEach((to, from, next) => {
//     iView.LoadingBar.start();
//     Util.title(to.meta.title);
//     next();
// });

// router.afterEach(() => {
//     iView.LoadingBar.finish();
//     window.scrollTo(0, 0);
// });


const store = new Vuex.Store({
    state: {

    },
    getters: {

    },
    mutations: {

    },
    actions: {

    }
});

Vue.prototype.ajax = Util.ajax;

new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App)
});